package com.wp.dao;

import com.wp.entity.Supplier;
import com.wp.entity.SysUser;
import com.wp.service.SupplierService;
import com.wp.service.SysUserService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

import static org.junit.Assert.*;

public class CvsDaoTest {

    ApplicationContext context = new ClassPathXmlApplicationContext("spring_cvs.xml");

    @Test
    public void login() {

        SysUserService sysUserService = context.getBean("sysUserService", SysUserService.class);

        SysUser sysUser = sysUserService.login("admin", "1111111");

        System.out.println(sysUser);
    }

    @Test
    public void findSupply() {
        SupplierService supplierService = context.getBean("supplierService", SupplierService.class);

        List<Supplier> supplier = supplierService.findSupply("BJ_GYS004","日技");

        for (Supplier supplier1 : supplier){
            System.out.println(supplier1);
        }
    }

    @Test
    public void upd() {
        SupplierService supplierService = context.getBean("supplierService", SupplierService.class);

        Supplier supplier = new Supplier();
        supplier.setId(1);
        supplier.setSupCode("BJ_GYS004");

        int upd = supplierService.upd(supplier);



        System.out.println(upd);

    }

    @Test
    public void queryUserListByPage() throws Exception {
        SysUserService sysUserService = context.getBean("sysUserService", SysUserService.class);

        List<SysUser> sysUsers = sysUserService.findUserByPage(1,5,"黄",1);
        for (SysUser sysUser:sysUsers){
            System.out.println(sysUser);
        }

    }
}